var heatMapLayer = new ol.layer.Heatmap({
    title: '热力图层',
    visible: true,
    source: new ol.source.Vector({
        /*url: 'js/data/heatmapdata.geojson',*/
        //json格式点图层，点密度决定热力图分布
        url: ' http://172.19.18.223:5555/rdbmsserver?table=qy',
        format: new ol.format.GeoJSON()
    }),
    blur: 30, //模糊程度
    radius: 20  //半径
});


$(function () {

    var element = document.createElement('div');
    element.setAttribute("id", "divHeatmap");

    var btnHeatmap = document.createElement("BUTTON");
    btnHeatmap.textContent = "显示热力图";
    btnHeatmap.setAttribute("id", "btnHeatmap");

    element.appendChild(btnHeatmap);
    element.className = 'ol-unselectable ol-control';
    document.body.appendChild(element); //将代码生成的要素添加到map div里面


    $("#btnHeatmap").click(function () {
        if ($("#btnHeatmap").text().trim() == "显示热力图") {
            $("#btnHeatmap").text("隐藏热力图");
            //setCenterZoom(13441031.015, 3673964.87, 12);
            YWLayer.getLayers().push(heatMapLayer);
        } else {
            $("#btnHeatmap").text("显示热力图");
            YWLayer.getLayers().remove(heatMapLayer);
        }
    });

})


